<template>
  <el-dialog
    title="新增"
    :visible.sync="dialogVisible"
    :before-close="close"
    width="30%"
  >
    <el-form label-width="100px">
      <el-form-item label="上级会议类型">
        <el-input disabled v-model="label" size="mini" />
      </el-form-item>
      <el-form-item label="会议类型名称">
        <el-input v-model="name" size="mini" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirm">确 定</el-button>
      <el-button @click="close">取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { treeAdd } from '@/api/onlineClassroom/partyConstitutionRegulations'
export default {
  data () {
    return {
      dialogVisible: false,
      name: '',
      parentId: 0,
      label: '最上级'
    }
  },
  methods: {
    open (id, label) {
      this.parentId = id
      if (label) {
        this.label = label
      }
      this.dialogVisible = true
    },
    confirm () {
      treeAdd({
        parentId: this.parentId,
        name: this.name
      }).then((res) => {
        this.$message.success('新增成功')
        this.$emit('updateTree', 0)
        this.close()
      })
    },
    close () {
      this.parentId = 0
      this.label = '最上级'
      this.meetingTypeName = ''
      this.dialogVisible = false
    }
  }
}
</script>
